home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!hpl3sn03.cern.ch
- From: Dan Pop <danpop@mail.cern.ch>
- Newsgroups: comp.lang.c
- Subject: Re: Segmentation fault at return statement. Can't figure out ....
- Date: Sat, 20 Jan 1996 19:45:18 +0100
- Organization: CERN European Lab for Particle Physics
- Message-ID: <9601201845.AA02887@dxmint.cern.ch>
- References: <4dm2n1$egk@murphy.servtech.com> <4dqgr3$626@clare.res.com>
- X-NNTP-Posting-Host: hpl3sn03.cern.ch
- X-Newsreader: NN version 6.5.0 #7 (NOV)
- X-Mail2News-Path: frigate.doc.ic.ac.uk!dxmint.cern.ch!hpl3sn03.cern.ch
-
- danlynes@res.com writes:
-
- >In <4dm2n1$egk@murphy.servtech.com>, Avijit Dasgupta <avi@servtech.com> writes:
- >
- >>83: return(999); <----- Segmentation fault at this stmt.
- >>}
- >>
- >>Running dbx I get these error messages:
- >>
- >>(dbx) where
- >>=> [1] test( ) at line 83
- >>dbx: bad data address
- >>dbx fetch at 0x697075a4 failed - I/O error
- >>dbx : attempt to read stack failed - bad frame pointer
- >>(dbx)
- >>
- >>I can't figure out, bcoz this function gets called multiple times and
- >>fails only after a fixed X times ... Any Help ?
- >
- >My guess would be that you're allocating some memory that you're
- >not freeing up, when returning from the function. So, after so
- >many calls to it, your stack gets filled up, and refuses to
- >continue running.
-
- Huh??? There is no malloc implementation that I know of which allocates
- memory on the stack.
-
- > i.e. You have a stack overflow error.
-
- If this is the case (not very likely) it is (probably) because he has
- too much automatic data or because of recursing too deeply.
-
- >Try
- >proofing your code, to see if there's any memory you're
- >forgetting to deallocate, either by by explicitly allocated
- >memory, or implicitly allocated memory.
-
- Memory leaks don't usually cause stack corruption.
-
- My guess (in the absence of enough information) is that the original poster
- was doing bad things with pointers and he managed to corrupt the
- information stored on the stack. When the cpu tried to fetch the
- return address from the stack, it got some garbage instead and the attempt
- to jump to that address caused the segmentation fault.
-
- >+------------------------------------------------------+
- >! OS/2 - The Champion of Operating Systems !
-
- It depends on who are the other competitors :-)
-
- Dan
- --
- Dan Pop
- CERN, CN Division
- Email: danpop@mail.cern.ch
- Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
-